//
//  TableViewNoDataView.m
//  LiveIMTool
//
//  Created by NeiQuan on 16/10/27.
//  Copyright © 2016年 AlexiChen. All rights reserved.
//

#import "TableViewNoDataView.h"

static float const kUIemptyOverlayLabelX         = 0;
static float const kUIemptyOverlayLabelY         = 0;
static float const kUIemptyOverlayLabelHeight    = 20;

@interface TableViewNoDataView ()
@property (nonatomic, strong)UIImageView *emptyOverlayImageView;
    
    
@end


@implementation TableViewNoDataView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self = [self sharedInit];
    }
    return self;
}
    
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self)
    {
        self = [self sharedInit];
    }
    return self;
}
    
- (instancetype)sharedInit
{
    self.backgroundColor = [UIColor whiteColor];
    self.backgroundColor = [UIColor whiteColor];
    self.contentMode =   UIViewContentModeTop;
    [self addUIemptyOverlayImageView];
    [self addUIemptyOverlayLabel];
    return self;
}

- (void)addUIemptyOverlayImageView {
    self.emptyOverlayImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    self.emptyOverlayImageView.center = CGPointMake(CGRectGetWidth(self.frame) / 2, CGRectGetHeight(self.frame) / 2 - 60);
    self.emptyOverlayImageView.image = [UIImage imageNamed:@"icon_jiazaishibai"];
    [self addSubview:self.emptyOverlayImageView];
}
    
- (void)addUIemptyOverlayLabel {
    CGRect emptyOverlayViewFrame = CGRectMake(kUIemptyOverlayLabelX, kUIemptyOverlayLabelY, CGRectGetWidth(self.frame), kUIemptyOverlayLabelHeight);
    UILabel *emptyOverlayLabel = [[UILabel alloc] initWithFrame:emptyOverlayViewFrame];
    emptyOverlayLabel.textAlignment = NSTextAlignmentCenter;
    emptyOverlayLabel.numberOfLines = 0;
    emptyOverlayLabel.backgroundColor = [UIColor clearColor];
    emptyOverlayLabel.text = @"╮(╯_╰)╭   暂无数据";
    emptyOverlayLabel.font = [UIFont boldSystemFontOfSize:15];
    emptyOverlayLabel.frame = ({
        CGRect frame = emptyOverlayLabel.frame;
        frame.origin.y = CGRectGetMaxY(self.emptyOverlayImageView.frame) + 10;
        frame;
    });
    emptyOverlayLabel.textColor = [UIColor grayColor];
    [self addSubview:emptyOverlayLabel];
}
    
//- (void)setupUIemptyOverlay
//{
//    self.userInteractionEnabled = YES;
//    UILongPressGestureRecognizer *longPressUIemptyOverlay = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressUIemptyOverlay:)];
//    [longPressUIemptyOverlay setMinimumPressDuration:0.001];
//    [self addGestureRecognizer:longPressUIemptyOverlay];
//    self.userInteractionEnabled = YES;
//}
//    
//- (void)longPressUIemptyOverlay:(UILongPressGestureRecognizer *)gesture {
//    if (gesture.state == UIGestureRecognizerStateBegan) {
//        self.emptyOverlayImageView.alpha = 0.4;
//    }
//    if ( gesture.state == UIGestureRecognizerStateEnded ) {
//        self.emptyOverlayImageView.alpha = 1;
//        if ([self.delegate respondsToSelector:@selector(emptyOverlayClicked:)]) {
//            [self.delegate emptyOverlayClicked:nil];
//        }
//    }
//}
@end
